from user.models import User
from .signals import notifications_sent
from django.views import View
from django.http import JsonResponse
from django.dispatch import Signal


class NotificationView(View):
    def post(self, request):
        user = request.GET.get('user')
        msg = request.GET.get('msg')
        print(user, msg)
        user_ = User.objects.get(username=user)
        notification_sent = Signal()
        # notification_sent.providing_args = ["user", "message"]

        dat = notification_sent.send(sender=None, user=user, message=msg)
        print(dat)
        return JsonResponse({'status': 'success'})

    def notifications_view(request):
        user_notifications = Notification.objects.filter(user=request.user)
        print(user_notifications)
        return JsonResponse(data="hahah")
    